# Listener

<div class="api-docs__separator" data-reactroot="">

---

</div><div class="api-docs__import" data-reactroot="">

```ts
import { Listener } from "@hyper-fetch/sockets";
```

</div><div class="api-docs__section">

## Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">

</span></div><p class="api-docs__definition">

Defined in
[listener/listener.ts:6](https://github.com/BetterTyped/hyper-fetch/blob/c3e2c45/packages/sockets/src/listener/listener.ts#L6)

</p><div class="api-docs__section">

## Parameters

</div>
<div class="api-docs__parameters">
<table>
<thead><tr><th>Name</th><th>Details</th></tr></thead>
<tbody><tr param-data="socket"><td class="api-docs__param-name required">

### socket

`Required`

</td><td class="api-docs__param-type">

`Socket<Adapter>`

</td></tr><tr param-data="listenerOptions"><td class="api-docs__param-name optional">

### listenerOptions

`Optional`

</td><td class="api-docs__param-type">

`ListenerOptionsType<ExtractListenerOptionsType<Adapter>>`

</td></tr></tbody></table></div><div class="api-docs__section">

## Properties

</div><div class="api-docs__properties"><div class="api-docs__property" property-data="listenerOptions"><h3 class="api-docs__name">

### `listenerOptions`

</h3><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">

</span></div><p class="api-docs__definition">

Defined in
[listener/listener.ts:12](https://github.com/BetterTyped/hyper-fetch/blob/c3e2c45/packages/sockets/src/listener/listener.ts#L12)

</p><div class="api-docs__section">

#### Type

</div><div class="api-docs__property-type">

```ts
ListenerOptionsType<ExtractListenerOptionsType<Adapter>>;
```

</div><hr/></div><div class="api-docs__property" property-data="name"><h3 class="api-docs__name">

### `name`

</h3><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">

</span></div><p class="api-docs__definition">

Defined in
[listener/listener.ts:7](https://github.com/BetterTyped/hyper-fetch/blob/c3e2c45/packages/sockets/src/listener/listener.ts#L7)

</p><div class="api-docs__section">

#### Type

</div><div class="api-docs__property-type">

```ts
string;
```

</div><hr/></div><div class="api-docs__property" property-data="options"><h3 class="api-docs__name">

### `options`

</h3><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">

</span></div><p class="api-docs__definition">

Defined in
[listener/listener.ts:8](https://github.com/BetterTyped/hyper-fetch/blob/c3e2c45/packages/sockets/src/listener/listener.ts#L8)

</p><div class="api-docs__section">

#### Type

</div><div class="api-docs__property-type">

```ts
ExtractListenerOptionsType<Adapter>;
```

</div><hr/></div><div class="api-docs__property" property-data="socket"><h3 class="api-docs__name">

### `socket`

</h3><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">

</span></div><p class="api-docs__definition">

Defined in
[listener/listener.ts:11](https://github.com/BetterTyped/hyper-fetch/blob/c3e2c45/packages/sockets/src/listener/listener.ts#L11)

</p><div class="api-docs__section">

#### Type

</div><div class="api-docs__property-type">

```ts
Socket<Adapter>;
```

</div><hr/></div></div><div class="api-docs__section">

## Methods

</div><div class="api-docs__methods"><div class="api-docs__method" method-data="clone"><h3 class="api-docs__name">

### `clone()`

</h3><div class="api-docs__section">

#### Preview

</div><div class="api-docs__preview fn">

```ts
clone(config);
```

</div><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">

</span></div><p class="api-docs__definition">

Defined in
[listener/listener.ts:23](https://github.com/BetterTyped/hyper-fetch/blob/c3e2c45/packages/sockets/src/listener/listener.ts#L23)

</p><div class="api-docs__section">

#### Parameters

</div>
<div class="api-docs__parameters">
<table>
<thead><tr><th>Name</th><th>Details</th></tr></thead>
<tbody><tr param-data="config"><td class="api-docs__param-name optional">

#### config

`Optional`

</td><td class="api-docs__param-type">

`Partial<ListenerOptionsType<ExtractListenerOptionsType<Adapter>>>`

</td></tr></tbody></table></div><div class="api-docs__section">

#### Return

</div><div class="api-docs__returns">

```ts
Listener<Response, Adapter>;
```

</div><hr/></div><div class="api-docs__method" method-data="listen"><h3 class="api-docs__name">

### `listen()`

</h3><div class="api-docs__section">

#### Preview

</div><div class="api-docs__preview fn">

```ts
listen(callback);
```

</div><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">

</span></div><p class="api-docs__definition">

Defined in
[listener/listener.ts:31](https://github.com/BetterTyped/hyper-fetch/blob/c3e2c45/packages/sockets/src/listener/listener.ts#L31)

</p><div class="api-docs__section">

#### Parameters

</div>
<div class="api-docs__parameters">
<table>
<thead><tr><th>Name</th><th>Details</th></tr></thead>
<tbody><tr param-data="callback"><td class="api-docs__param-name required">

#### callback

`Required`

</td><td class="api-docs__param-type">

`ListenerCallbackType<Response>`

</td></tr></tbody></table></div><div class="api-docs__section">

#### Return

</div><div class="api-docs__returns">

```ts
readonly [() => void, ListenerCallbackType<Response>]
```

</div><hr/></div><div class="api-docs__method" method-data="setOptions"><h3 class="api-docs__name">

### `setOptions()`

</h3><div class="api-docs__section">

#### Preview

</div><div class="api-docs__preview fn">

```ts
setOptions(options);
```

</div><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">

</span></div><p class="api-docs__definition">

Defined in
[listener/listener.ts:19](https://github.com/BetterTyped/hyper-fetch/blob/c3e2c45/packages/sockets/src/listener/listener.ts#L19)

</p><div class="api-docs__section">

#### Parameters

</div>
<div class="api-docs__parameters">
<table>
<thead><tr><th>Name</th><th>Details</th></tr></thead>
<tbody><tr param-data="options"><td class="api-docs__param-name required">

#### options

`Required`

</td><td class="api-docs__param-type">

`ExtractListenerOptionsType<Adapter>`

</td></tr></tbody></table></div><div class="api-docs__section">

#### Return

</div><div class="api-docs__returns">

```ts
Listener<Response, Adapter>;
```

</div><hr/></div></div>
